import request from "@/utils/request";

export function getRolesByGroup(params) {
  return request({
    url: "/flows/template/getRolesByGroup",
    method: "get",
    params,
  });
}

// 获取可用的模板
export function availableTemplate(data) {
  return request({
    url: "/biz/flow/availableTemplate",
    method: "post",
    data: data,
  });
}

// 保存为草稿
export function saveAsDraft(data) {
  return request({
    url: "/biz/flow/saveAsDraft",
    method: "post",
    data: data,
  });
}

// 发布流程
export function publish(data) {
  return request({
    url: "/biz/flow/publish",
    method: "post",
    data: data,
  });
}

// 获取当前用户的流程信息
export function getFlows(data) {
  return request({
    url: `/biz/flow/getFlows?pageNum=${data.pageNum}&pageSize=${data.pageSize}`,
    method: "post",
    data: data,
  });
}

// 根据编号获取流程
export function getFlowByNo(params) {
  return request({
    url: "/biz/flow/getFlowByNo",
    method: "get",
    params,
  });
}

// 获取指定流程节点审批人
export function getNodeUsers(data) {
  return request({
    url: "/biz/flow/getNodeUsers",
    method: "post",
    data: data,
  });
}

// 获取指定流程的操作历史
export function getFlowLog(params) {
  return request({
    url: "/biz/flow/getFlowLog",
    method: "get",
    params,
  });
}

// 流程审批
export function approval(data) {
  return request({
    url: "/biz/flow/approval",
    method: "post",
    data: data,
  });
}

// 用户对该流程的可操作性
export function getAvailableOption(params) {
  return request({
    url: "/biz/flow/getAvailableOption",
    method: "get",
    params,
  });
}

// 查询客户准入信息列表
export function listCustomerAdmit(query) {
  return request({
    url: "/customerAdmit/list",
    method: "get",
    params: query,
  });
}

// 客户准入详情查询
export function customerAdmitInfo(customerId) {
  return request({
    url: "/customerAdmit/info",
    method: "post",
    data: {
      customerId,
    },
  });
}

export function listScore(params) {
  return request({
    url: "/tenant/score/list",
    method: "get",
    params,
  });
}

// 获取授信评分
export function listCreditLevel(params) {
  return request({
    url: "/flcompany/config/creditLevel/list",
    method: "get",
    params,
  });
}

// 获取客户最近一次评分授信信息
export function customerCreditInfo(params) {
  return request({
    url: "/tenant/creditInfo/getInfoByCustomer",
    method: "get",
    params,
  });
}

// 获取代理商
export function agentList(params) {
  return request({
    url: "/agent/list",
    method: "get",
    params,
  });
}

// 获取设备
export function equipmentList(params) {
  return request({
    url: "/agent/equipment/listByCompanyCode",
    method: "get",
    params,
  });
}

// 租金测算
export function getrentCalculate(data) {
  return request({
    url: "/finance/rent/rentCalculate",
    method: "post",
    data: data,
  });
}

// 租金测算下载
export function rentCalculateDownload(data) {
  return request({
    url: "/finance/rent/rentCalculateDownload",
    method: "post",
    data: data,
    responseType: "blob",
  });
}

// 获取文件信息
export const getSimpleFileInfo = (data) => {
  return request({
    url: "/biz/file/getSimpleFileInfo",
    method: "post",
    data: data,
  });
};

// 获取合同模板
export function contractList(params) {
  return request({
    url: "/ContractTemplate/list",
    method: "get",
    params,
  });
}

// 生成随机编号
export function creatContractCode(data) {
  return request({
    url: "/contractInfo/creatContractCode",
    method: "post",
    data: data,
  });
}

// 文件下载预览
export const queryFiles = (params) => {
  return request({
    url: "/biz/file/get",
    method: "get",
    params,
    responseType: "blob",
  });
};

// 获取融资公司flcompany或者工厂列表factory
export function getCompanyList(companyType) {
  return request({
    url: "/ext/getCompanyListByType",
    method: "get",
    params: {
      companyType,
    },
  });
}

// 合同制定
export function contractTemplateCreate(data) {
  return request({
    url: "/contractInfo/create",
    method: "post",
    data: data,
  });
}

// 获取合同编号
export function creatContractId(data) {
  return request({
    url: "/contractInfo/creatContractId",
    method: "post",
    data: data,
  });
}

// 获取立项列表
export function projectApplyList(params) {
  return request({
    url: "/agent/projectApply/list",
    method: "get",
    params,
  });
}
// 获取立项详情
export function projectApplyInfo(params) {
  return request({
    url: "/agent/projectApply",
    method: "get",
    params,
  });
}

// 合同制定校验
export function checkContractCreate(data) {
  return request({
    url: "/contractInfo/checkContractCreate?id=" + data.id,
    method: "post",
  });
}

export function addCustomerBank(data) {
  return request({
    url: "/customerBankInfo/add",
    method: "post",
    data,
  });
}

export function editCustomerBank(data) {
  return request({
    url: "/customerBankInfo/edit",
    method: "post",
    data,
  });
}

export function removeCustomerBank(data) {
  return request({
    url: "/customerBankInfo/remove",
    method: "post",
    data: data,
  });
}

export function allCustomerBank(data) {
  return request({
    url: "/customerBankInfo/conditionlist",
    method: "post",
    data,
  });
}

// 合同发起其他附件上传
export function addAttachFile(data) {
  return request({
    url: "/contractFileInfo/addAttachFile",
    method: "post",
    data,
  });
}

// 获取项目签署的合同
export function alllist(data) {
  return request({
    url: "/contractInfo/alllist",
    method: "post",
    data,
  });
}

// 获取设备
export function getinfoByProjectId(data) {
  return request({
    url: "/projectEquipment/getinfoByProjectId",
    method: "post",
    data,
  });
}

// 起租应收列表
export function rentReceivableList(params) {
  return request({
    url: "/rentReceivable/list",
    method: "get",
    params,
  });
}

// 客户列表查询
export function customerList(params) {
  return request({
    url: "/customer/list",
    method: "get",
    params,
  });
}
// 修改
export function customerEdit(data) {
  return request({
    url: "/customer/edit",
    method: "post",
    data: data,
  });
}
// 客户详情
export function customerInfo(data) {
  return request({
    url: "/customer/info",
    method: "post",
    data: data,
  });
}

// 获取企业性质
export function getNature() {
  return request({
    url: "/flcompany/config/company/list",
    method: "get",
  });
}

// 获取客户最近一次评分授信信息
export function configCreditLevelList(params) {
  return request({
    url: `/factory/config/creditLevel/${params}`,
    method: "get", // params,
  });
}

// 获取代理商详情
export function agentDetail(data) {
  return request({
    url: "/agent/detail",
    method: "post",
    data: data,
  });
}